package com.spring.cn.annotation.repository.impl;

import com.spring.cn.annotation.UserBean;
import com.spring.cn.annotation.repository.UserRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

/**
 * @author liangd
 * date 2020-11-14 15:42
 * code @Repository(value = "userRepository"),如果Repository有多个实现，可以指定value值，参数名与service层指定参数一致
 *      也可以与@Qualifier连用
 */
//@Repository(value = "userRepository")
@Repository()
public class UserRepositoryImpl implements UserRepository {

    /**
     * 如果想设置bean不自动装配，可以设置required属性为false
     */
    @Autowired(required = false)
    private UserBean userBean;

    @Override
    public void save() {
        System.out.println("UserRepositoryImpl  save...");
        System.out.println(userBean);
    }
}
